{% extends "BackendBundle::backend.html.twig" %}

{% set vars = {'ruta' : app.request.attributes.get('_route')} %}

{% block title %}{{ "Administracion Seccion"|trans }}{% endblock %}

{% if modi == 2 %}

    {% set nombre = "" %}
    {% set idseccion = "" %}
    {% set idsecciondes = "" %}
    {% set desc = "" %}
    {% set publicado = "" %}
    {% set visible = "" %}

    {% set titletag = "" %}
    {% set keywordstag = "" %}
    {% set desctag = "" %}
    {% set urlfriendlytag = "" %}

{% elseif modi == 1 %}

    {% set nombre = secciotradu.nomseccion %}
    {% set idseccion = caterela %}
    {% set idsecciondes = secciotradu.idseccion %}
    {% set desc = secciotradu.descripcio %}
    {% set publicado = secciotradu.published %}
    {% set visible = secciotradu.visible %}

    {% set titletag = secciometas.title %}
    {% set keywordstag = secciometas.keywords %}
    {% set desctag = secciometas.description %}
    {% set urlfriendlytag = secciometas.urlfriendly %}

{% else %}
    
    {% set nombre = "" %}
    {% set idseccion = "" %}
    {% set idsecciondes = "" %}
    {% set desc = "" %}
    {% set publicado = "" %}
    {% set visible = "" %}

    {% set titletag = "" %}
    {% set keywordstag = "" %}
    {% set desctag = "" %}
    {% set urlfriendlytag = "" %}
    
{% endif %}

{% block header %}

    {% include "BackendBundle::topmenu.html.twig" with vars %}

{% endblock %}

{% block left %}

    {% include "ContentBundle:Hotel:menuleft.html.twig" with vars %}

{% endblock %}

{% block content %}

    <div class="span9">
    
        <h2>{{ "Contenido"|trans }}</h2>

        <fieldset>
            
            {% if modi == 2 %}
                <legend>{{ "Traduccion Seccion"|trans }}</legend>
            {% elseif modi == 1 %}
                <legend>{{ "Modificando Seccion"|trans }}</legend>
            {% else %}
                <legend>{{ "Añadir seccion para"|trans }} "{{hotel.hotelname}}"</legend>
            {% endif %}
            
            {% if app.session.hasFlash('success') %}
                <div class="flash-notice alert alert-success">
                    <h4 class="alert-heading">{{ "Ok"|trans }}!</h4>                     
                    {{ app.session.flash('success') }}
                </div>
            {% endif %}

            {% if app.session.hasFlash('error') %}
                <div class="flash-notice alert alert-error">
                    <h4 class="alert-heading">{{ "Error"|trans }}!</h4>                        
                    {{ app.session.flash('error') }}
                </div>
            {% endif %}

            {% if app.session.hasFlash('info') %}
                <div class="flash-notice alert alert-info">
                    <h4 class="alert-heading">{{ "Info"|trans }}!</h4>
                    <p>{{ app.session.flash('info') }}</p>
                </div>
            {% endif %}
            
            {% if modi == 2 %}
            <form action="{{ path('ContentBundle_secciones_tradu_save') }}" class="form-horizontal" method="post">            
            {% elseif modi == 1 %}
            <form action="{{ path('ContentBundle_secciones_edit_save') }}" class="form-horizontal" method="post">
            {% else %}
            <form action="{{ path('ContentBundle_secciones_save') }}" class="form-horizontal" method="post">
            {% endif %}
                
                <fieldset>
                    <div class="control-group">
                        <label class="control-label" for="nombre">{{ "Nombre"|trans }} *</label>
                        <div class="controls">
                            <input class="input-xlarge" id="nombre" name="nombre" type="text" value="{{ nombre }}" />
                        </div>
                    </div>
                        
                    {% if modi != 2 %}
                        
                    <div class="control-group">
                        <label class="control-label" for="seccion">{{ "Relacion"|trans }}</label>
                        <div class="controls">
                            <select id="seccion" name="seccion">
                                <option value="0"></option>
                                
                                {% if modi == 1 %}
                                
                                    {% set refArray = [] %}

                                    {% for ar in arbre %}

                                        {% if idsecciondes != ar.anterior %}

                                            {% if ar.anterior in refArray %}

                                                {% set refArray = refArray|merge([ar.id]) %} 

                                            {% else %}

                                                {% if idsecciondes != ar.id %}
                                                    <option value="{{ ar.id }}"{% if idseccion==ar.id %} selected="selected"{% endif %}>{{ ar.text }}</option>
                                                {% endif %}

                                            {% endif %}

                                        {% else %}

                                            {% set refArray = refArray|merge([ar.id]) %} 

                                        {% endif %}

                                    {% endfor %}
                                                
                                {% else %}
                                                    
                                    {% for ar in arbre %}            
                                        <option value="{{ ar.id }}">{{ ar.text }}</option>
                                    {% endfor %}
                
                                {% endif %}
                                                
                            </select>

                        </div>
                    </div>
                        
                    {% endif %}                        
                        
                    <div class="control-group">
                        <label class="control-label" for="desc">{{ "Descripción"|trans }} *</label>
                        <div class="controls">
                            <textarea class="input-xlarge" name="desc" id="desc" rows="3">{{ desc }}</textarea>
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label">{{ "Visible en la web"|trans }}</label>
                        <div class="controls row-fluid">
                            <div class="span1">
                                <label class="radio">
                                    <input name="visible" id="optionsRadios1" value="1" type="radio"{% if visible == 1 %} checked="checked"{% endif %} />
                                    {{ "Si"|trans }}
                                </label>
                            </div>
                            <div class="span1">   
                                <label class="radio">
                                    <input name="visible" id="optionsRadios2" value="0" type="radio"{% if visible == 0 %} checked="checked"{% endif %} />
                                    {{ "No"|trans }}
                                </label>
                            </div>
                        </div>
                    </div>
                        
                    <div class="control-group">
                        <label class="control-label">{{ "Publicado"|trans }}</label>
                        <div class="controls row-fluid">
                            <div class="span1">
                                <label class="radio">
                                    <input name="publicado" id="optionsRadios1" value="1" type="radio"{% if publicado == 1 %} checked="checked"{% endif %} />
                                    {{ "Si"|trans }}
                                </label>
                            </div>
                            <div class="span1">   
                                <label class="radio">
                                    <input name="publicado" id="optionsRadios2" value="0" type="radio"{% if publicado == 0 %} checked="checked"{% endif %} />
                                    {{ "No"|trans }}
                                </label>
                            </div>
                        </div>
                    </div>
                        
                </fieldset>
                <fieldset>
                    
                    <legend><small>{{ "Metatags"|trans }}</small></legend>

                    <div class="control-group">
                        <label class="control-label" for="titletag">{{ "Title"|trans }} *</label>
                        <div class="controls">
                            <input class="input-xlarge" id="titletag" name="titletag" type="text" value="{{ titletag }}" />
                        </div>
                    </div>                  
                    <div class="control-group">
                        <label class="control-label" for="Keywordstag">{{ "Keywords"|trans }}</label>
                        <div class="controls">
                            <input class="input-xlarge" id="Keywordstag" name="Keywordstag" type="text" value="{{ keywordstag }}" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="desctag">{{ "Description"|trans }}</label>
                        <div class="controls">
                            <textarea class="input-xlarge" name="desctag" id="desctag" rows="3">{{ desctag }}</textarea>
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label" for="urlfriendlytag">{{ "Url Friendly"|trans }} *</label>
                        <div class="controls">
                            <input class="input-xlarge" id="urlfriendlytag" name="urlfriendlytag" type="text" value="{{ urlfriendlytag }}" />
                        </div>
                    </div>                      
                        
                    <div class="form-actions">
                        
                        {% if modi == 2 %}
                            <button type="submit" name="DadesGuardaCrea" class="btn btn-primary">{{ "Guardar traduccio"|trans }}</button>
                            <a href="{{ path("ContentBundle_secciones_list_idioma", {'ididioma': ididioma}) }}" class="btn">{{ "Cancelar"|trans }}</a>
                        {% elseif modi == 1 %}
                            <button type="submit" name="DadesGuardaModi" class="btn btn-primary">{{ "Guardar"|trans }}</button>
                            <a href="{{ path("ContentBundle_secciones_list_idioma", {'ididioma': ididioma}) }}" class="btn">{{ "Cancelar"|trans }}</a>
                        {% else %}
                            <button type="submit" name="DadesGuarda" class="btn btn-primary">{{ "Añadir Seccion"|trans }}</button>
                            <a href="{{ path('ContentBundle_secciones_list') }}" class="btn">{{ "Cancelar"|trans }}</a>
                        {% endif %}

                    </div>
                </fieldset>
                    
            </form>

        </fieldset>
        
    </div>

{% endblock %}
